package com.itpengwei.strategy;

/**
 * @author: pengwei
 * @date: 2019/11/28 2:45 下午
 * 测试策略demo
 */
public class StrategyTest {
    private static void testIntegral() {
        IntegralPayment integralPayment = new IntegralPayment();
        PaymentContext context = new PaymentContext();
        context.setPaymentMethodBase(integralPayment);
        System.out.println("使用积分策略---输入100，输出==》" + context.getResult(100));
    }

    private static void testCoupon() {
        CouponPayment couponPayment = new CouponPayment();
        PaymentContext context = new PaymentContext();
        context.setPaymentMethodBase(couponPayment);
        System.out.println("使用优惠券策略---输入100，输出==》" + context.getResult(100));
    }

    private static void testCashcoupon() {
        CashcouponPayment cashcouponPayment = new CashcouponPayment();
        PaymentContext context = new PaymentContext();
        context.setPaymentMethodBase(cashcouponPayment);
        System.out.println("使用代金券策略---输入100，输出==》" + context.getResult(100));
    }

    public static void main(String[] args) {
        testIntegral();
        testCoupon();
        testCashcoupon();
    }
}
